﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using BLL;
using WcfServices.ServiceInterfaces;
using EntitiesLayer;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System.Net;
using System.Data.SqlClient;
using WcfServices.Utilities;
using System.IO;
using System.Drawing;

namespace WcfServices
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class TipoCitaService : ITipoCitaService
    {
        private GestorTipoCita gestor;

        public TipoCitaService() {
            gestor = new GestorTipoCita();
        }

        public string Listar()
        {
            IEnumerable<TipoCita> listaTipoCitas =
                Util.interceptWithReturn(gestor.listarTipoCitas);

            if (listaTipoCitas != null)
                return listaTipoCitas.JsonSerialize(ignoreTypes: new[] { typeof(IList<>) });

            return "";
        }

        public string BuscarPorId(int id)
        {
            TipoCita tipocita =
                Util.interceptWithReturn(() => gestor.getTipoCitaById(id));

            if (tipocita != null)
                return tipocita.JsonSerialize(ignoreTypes: new[] { typeof(IList<>) });

            return "";
        }
    }
}
